<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="utf-8">
  

  
  <title>软件学院ACM集训队选拔赛第一场 | Tootal World</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="题目 AU53614 电梯注意不存在0楼。">
<meta name="keywords" content="ACM">
<meta property="og:type" content="article">
<meta property="og:title" content="软件学院ACM集训队选拔赛第一场">
<meta property="og:url" content="http://tootal.xyz/2018/11/26/软件学院ACM集训队选拔赛第一场/index.html">
<meta property="og:site_name" content="Tootal World">
<meta property="og:description" content="题目 AU53614 电梯注意不存在0楼。">
<meta property="og:locale" content="default">
<meta property="og:updated_time" content="2018-12-16T10:07:40.162Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="软件学院ACM集训队选拔赛第一场">
<meta name="twitter:description" content="题目 AU53614 电梯注意不存在0楼。">
  
    <link rel="alternate" href="../../../../atom.xml" title="Tootal World" type="application/atom+xml">
  
  
    <link rel="icon" href="http://tootal.xyz/favicon.png">
  
  
    <link href="http://fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="../../../../css/style.css">
</head>
</html>
<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="../../../../index.html" id="logo">Tootal World</a>
      </h1>
      
        <h2 id="subtitle-wrap">
          <a href="../../../../index.html" id="subtitle">在时光的流逝中，逐渐成为更好的自己。</a>
        </h2>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="../../../../index.html">Home</a>
        
          <a class="main-nav-link" href="../../../../archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="../../../../atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
		<!--below use google search-->
        <!--%- search_form({button: '&#xF002;'}) %-->
		<!--below use baidu search-->
		 <!--form action="http://www.baidu.com/baidu" method="get" accept-charset="utf-8" class="search-form">
          <input type="search" name="word" maxlength="20" class="search-form-input" placeholder="Search">
          <input type="submit" value="" class="search-form-submit">
          <input name=tn type=hidden value="bds">
          <input name=cl type=hidden value="3">
          <input name=ct type=hidden value="2097152">
          <input type="hidden" name="si" value="tootal.xyz">
        </form-->
		<!--below use swiftype search-->
		<!--input type="search" name="word" maxlength="20" class="st-default-search-input" placeholder="Search"-->
		<input type="text" class="st-default-search-input">
		<script type="text/javascript">
			(function(w,d,t,u,n,s,e){w['SwiftypeObject']=n;w[n]=w[n]||function(){
			(w[n].q=w[n].q||[]).push(arguments);};s=d.createElement(t);
			e=d.getElementsByTagName(t)[0];s.async=1;s.src=u;e.parentNode.insertBefore(s,e);
			})(window,document,'script','//s.swiftypecdn.com/install/v2/st.js','_st');
			_st('install','PwDt_XJKCzu2LMzrR5qV','2.0.0');
		</script>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-软件学院ACM集训队选拔赛第一场" class="article article-type-post" itemscope="" itemprop="blogPost">
  <div class="article-meta">
    <a href="index.html" class="article-date">
  <time datetime="2018-11-25T16:40:18.000Z" itemprop="datePublished">2018-11-26</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      软件学院ACM集训队选拔赛第一场
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p><a href="https://www.luogu.org/contestnew/show/13317" target="_blank" rel="noopener">题目</a></p>
<h1 id="A"><a href="index.html#A" class="headerlink" title="A"></a>A</h1><p><a href="https://www.luogu.org/problemnew/show/U53614" target="_blank" rel="noopener">U53614 电梯</a><br>注意不存在0楼。<br><a id="more"></a></p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line"><span class="comment">//	freopen("input.txt","r",stdin);</span></span><br><span class="line">    <span class="keyword">int</span> t;</span><br><span class="line">    <span class="built_in">cin</span>&gt;&gt;t;</span><br><span class="line">    <span class="keyword">while</span>(t--)&#123;</span><br><span class="line">        <span class="keyword">int</span> h,l,n,m=<span class="number">1</span>;</span><br><span class="line">        <span class="built_in">cin</span>&gt;&gt;h&gt;&gt;l&gt;&gt;n;</span><br><span class="line">        <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=n;i++)&#123;</span><br><span class="line">            <span class="keyword">char</span> c;<span class="keyword">int</span> a;</span><br><span class="line">            <span class="built_in">cin</span>.get();</span><br><span class="line">            <span class="built_in">cin</span>&gt;&gt;c&gt;&gt;a;</span><br><span class="line">            <span class="keyword">if</span>(c==<span class="string">'u'</span>)&#123;</span><br><span class="line">                <span class="keyword">if</span>(m&lt;<span class="number">0</span>&amp;&amp;m+a&gt;=<span class="number">0</span>)m++;</span><br><span class="line">                m+=a;</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">else</span> <span class="keyword">if</span>(c==<span class="string">'d'</span>)&#123;</span><br><span class="line">                <span class="keyword">if</span>(m&gt;<span class="number">0</span>&amp;&amp;m-a&lt;=<span class="number">0</span>)m--;</span><br><span class="line">                m-=a;</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span>(m&gt;h)m=h;</span><br><span class="line">            <span class="keyword">else</span> <span class="keyword">if</span>(m&lt;l)m=l;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="built_in">cout</span>&lt;&lt;m&lt;&lt;<span class="built_in">endl</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="B"><a href="index.html#B" class="headerlink" title="B"></a>B</h1><p><a href="https://www.luogu.org/problemnew/show/U53615" target="_blank" rel="noopener">U53615 集训室的猫</a><br>解法比较多，这里采用了矩阵快速幂。</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstring&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> M=<span class="number">1000007</span>;</span><br><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">Matrix</span>&#123;</span></span><br><span class="line">    <span class="keyword">long</span> <span class="keyword">long</span> a[<span class="number">3</span>][<span class="number">3</span>];</span><br><span class="line">    Matrix()&#123;</span><br><span class="line">        <span class="built_in">memset</span>(a,<span class="number">0</span>,<span class="keyword">sizeof</span>(a));</span><br><span class="line">    &#125;</span><br><span class="line">&#125;;</span><br><span class="line">Matrix <span class="keyword">operator</span>*(<span class="keyword">const</span> Matrix &amp;x,<span class="keyword">const</span> Matrix &amp;y)&#123;</span><br><span class="line">    Matrix ans;</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=<span class="number">2</span>;i++)&#123;</span><br><span class="line">        <span class="keyword">for</span>(<span class="keyword">int</span> j=<span class="number">1</span>;j&lt;=<span class="number">2</span>;j++)&#123;</span><br><span class="line">            <span class="keyword">for</span>(<span class="keyword">int</span> k=<span class="number">1</span>;k&lt;=<span class="number">2</span>;k++)&#123;</span><br><span class="line">                ans.a[i][j]=(ans.a[i][j]+x.a[i][k]*y.a[k][j])%M;</span><br><span class="line">                <span class="comment">//while(ans.a[i][j]&gt;=M)ans.a[i][j]-=M;</span></span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> ans;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">init</span><span class="params">(Matrix &amp;x)</span></span>&#123;</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=<span class="number">2</span>;i++)&#123;</span><br><span class="line">        x.a[i][i]=<span class="number">1</span>;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">Matrix <span class="keyword">operator</span>^(Matrix &amp;x,<span class="keyword">int</span> y)&#123;</span><br><span class="line">    Matrix ans;</span><br><span class="line">    init(ans);</span><br><span class="line">    <span class="keyword">while</span>(y)&#123;</span><br><span class="line">        <span class="keyword">if</span>(y&amp;<span class="number">1</span>)&#123;</span><br><span class="line">            ans=ans*x;</span><br><span class="line">        &#125;</span><br><span class="line">        x=x*x;</span><br><span class="line">        y&gt;&gt;=<span class="number">1</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> ans;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">    <span class="comment">//freopen("input.txt","r",stdin);</span></span><br><span class="line">    <span class="comment">//freopen("output.txt","w",stdout);</span></span><br><span class="line">    <span class="keyword">int</span> t;</span><br><span class="line">    <span class="built_in">cin</span>&gt;&gt;t;</span><br><span class="line">    <span class="keyword">while</span>(t--)&#123;</span><br><span class="line">        <span class="keyword">int</span> n,a,b;</span><br><span class="line">        <span class="built_in">cin</span>&gt;&gt;n&gt;&gt;a&gt;&gt;b;</span><br><span class="line">        <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=n;i++)&#123;</span><br><span class="line">            <span class="keyword">int</span> x;</span><br><span class="line">            <span class="built_in">cin</span>&gt;&gt;x;</span><br><span class="line">            <span class="keyword">if</span>(x==<span class="number">1</span>)<span class="built_in">cout</span>&lt;&lt;a;</span><br><span class="line">            <span class="keyword">else</span> <span class="keyword">if</span>(x==<span class="number">2</span>)<span class="built_in">cout</span>&lt;&lt;b;</span><br><span class="line">            <span class="keyword">else</span>&#123;</span><br><span class="line">                Matrix m;</span><br><span class="line">                m.a[<span class="number">1</span>][<span class="number">1</span>]=m.a[<span class="number">1</span>][<span class="number">2</span>]=m.a[<span class="number">2</span>][<span class="number">1</span>]=<span class="number">1</span>;</span><br><span class="line">                m=m^(x<span class="number">-2</span>);</span><br><span class="line">                <span class="built_in">cout</span>&lt;&lt;(m.a[<span class="number">1</span>][<span class="number">1</span>]*b+m.a[<span class="number">1</span>][<span class="number">2</span>]*a)%M;</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span>(i==n)<span class="built_in">cout</span>&lt;&lt;<span class="string">'\n'</span>;</span><br><span class="line">            <span class="keyword">else</span> <span class="built_in">cout</span>&lt;&lt;<span class="string">' '</span>;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="C"><a href="index.html#C" class="headerlink" title="C"></a>C</h1><p><a href="https://www.luogu.org/problemnew/show/U53616" target="_blank" rel="noopener">U53616 步道乐骑</a><br>类似与生成树。</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;vector&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> N=<span class="number">100050</span>;</span><br><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">edge</span>&#123;</span></span><br><span class="line">    <span class="keyword">int</span> u,v,w;</span><br><span class="line">    edge(<span class="keyword">int</span> u,<span class="keyword">int</span> v,<span class="keyword">int</span> w):u(u),v(v),w(w) &#123;&#125;</span><br><span class="line">    <span class="keyword">bool</span> <span class="keyword">operator</span>&lt;(<span class="keyword">const</span> edge &amp;x)<span class="keyword">const</span>&#123;</span><br><span class="line">        <span class="keyword">return</span> w&gt;x.w;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;;</span><br><span class="line"><span class="built_in">vector</span>&lt;edge&gt; e;</span><br><span class="line"><span class="keyword">int</span> x[N],y[N],w[N],Set[N];</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">Find</span><span class="params">(<span class="keyword">int</span> x)</span></span>&#123;</span><br><span class="line">    <span class="keyword">return</span> (x==Set[x])?x:Set[x]=Find(Set[x]);</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">Union</span><span class="params">(<span class="keyword">int</span> x,<span class="keyword">int</span> y)</span></span>&#123;</span><br><span class="line">    Set[Find(x)]=Set[Find(y)];</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">    <span class="comment">//freopen("input.txt","r",stdin);</span></span><br><span class="line">    <span class="keyword">int</span> n,m,k;</span><br><span class="line">    <span class="built_in">cin</span>&gt;&gt;n&gt;&gt;m&gt;&gt;k;</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=m;i++)&#123;</span><br><span class="line">        <span class="built_in">cin</span>&gt;&gt;x[i]&gt;&gt;y[i]&gt;&gt;w[i];</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">int</span> u,v;</span><br><span class="line">    <span class="built_in">cin</span>&gt;&gt;u&gt;&gt;v;</span><br><span class="line">    <span class="keyword">int</span> ans=<span class="number">0</span>;</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=m;i++)&#123;</span><br><span class="line">        <span class="keyword">if</span>((x[i]==u&amp;&amp;y[i]==v)||(x[i]==v&amp;&amp;y[i]==u))&#123;</span><br><span class="line">            ans=max(ans,w[i]);</span><br><span class="line">        &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">            e.push_back(edge(x[i],y[i],w[i]));</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=n;i++)Set[i]=i;</span><br><span class="line">    Union(u,v);</span><br><span class="line">    k--;</span><br><span class="line">    sort(e.begin(),e.end());</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">auto</span> i:e)&#123;</span><br><span class="line">        <span class="keyword">if</span>(k==<span class="number">0</span>)<span class="keyword">break</span>;</span><br><span class="line">        <span class="keyword">if</span>(Find(i.u)!=Find(i.v))&#123;</span><br><span class="line">            ans+=i.w;</span><br><span class="line">            Union(i.u,i.v);</span><br><span class="line">            k--;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="built_in">cout</span>&lt;&lt;ans&lt;&lt;<span class="built_in">endl</span>;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="D"><a href="index.html#D" class="headerlink" title="D"></a>D</h1><p><a href="https://www.luogu.org/problemnew/show/U53617" target="_blank" rel="noopener">U53617 翘爆团体</a><br>图论题。艰难 。。</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstring&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;vector&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;stack&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> N=<span class="number">5050</span>;</span><br><span class="line"><span class="built_in">vector</span>&lt;<span class="keyword">int</span>&gt; edge[N];</span><br><span class="line"><span class="built_in">stack</span>&lt;<span class="keyword">int</span>&gt; stk;</span><br><span class="line"><span class="keyword">int</span> dfn[N],low[N],instk[N],mark[N],match[N],vis[N];</span><br><span class="line"><span class="built_in">vector</span>&lt;<span class="keyword">int</span>&gt; cut[N];</span><br><span class="line"><span class="keyword">int</span> times,scc,mat;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">tarjan</span><span class="params">(<span class="keyword">int</span> u)</span></span>&#123;</span><br><span class="line">    <span class="comment">//printf("tarjan(%d) begin!\n",u);</span></span><br><span class="line">    dfn[u]=low[u]=++times;</span><br><span class="line">    stk.push(u);</span><br><span class="line">    instk[u]=<span class="number">1</span>;</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">auto</span> v:edge[u])&#123;</span><br><span class="line">        <span class="keyword">if</span>(!dfn[v])&#123;</span><br><span class="line">            tarjan(v);</span><br><span class="line">            low[u]=min(low[u],low[v]);</span><br><span class="line">            <span class="comment">//printf("when tarjan(%d),v not visted,low[%d]=%d\n",u,u,low[u]);</span></span><br><span class="line">        &#125;<span class="keyword">else</span> <span class="keyword">if</span>(instk[v])&#123;</span><br><span class="line">            low[u]=min(low[u],dfn[v]);</span><br><span class="line">            <span class="comment">//printf("when tarjan(%d),v in stack,low[%d]=%d\n",u,u,low[u]);</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">//printf("when tarjan(%d),dfn[%d]=%d,low[%d]=%d\n",u,u,dfn[u],u,low[u]);</span></span><br><span class="line">    <span class="keyword">if</span>(dfn[u]==low[u])&#123;</span><br><span class="line">        <span class="keyword">int</span> v;</span><br><span class="line">        <span class="keyword">do</span>&#123;</span><br><span class="line">            v=stk.top();</span><br><span class="line">            <span class="comment">//printf("when tarjan(%d),v=%d\n",u,v);</span></span><br><span class="line">            instk[v]=<span class="number">0</span>;</span><br><span class="line">            mark[v]=scc;</span><br><span class="line">            <span class="comment">//for(auto i:edge[v])</span></span><br><span class="line">            <span class="comment">//	cut[scc].push_back(i);</span></span><br><span class="line">            stk.pop();</span><br><span class="line">        &#125;<span class="keyword">while</span>(v!=u);</span><br><span class="line">        scc++;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">//printf("ans=%d,dfn[%d]=%d,low[%d]=%d,tarjan(%d) end!\n",ans,u,dfn[u],u,low[u],u);</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">dfs</span><span class="params">(<span class="keyword">int</span> u)</span></span>&#123;</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">auto</span> v:cut[u])&#123;</span><br><span class="line">        <span class="keyword">if</span>(u!=v&amp;&amp;!vis[v])&#123;</span><br><span class="line">            vis[v]=<span class="number">1</span>;</span><br><span class="line">            <span class="keyword">if</span>(match[v]==<span class="number">-1</span>||dfs(match[v]))&#123;</span><br><span class="line">                match[v]=u;</span><br><span class="line">                <span class="comment">//match[u]=v;</span></span><br><span class="line">                <span class="comment">//printf("match %d %d\n",u,v);</span></span><br><span class="line">                <span class="keyword">return</span> <span class="number">1</span>;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">    <span class="comment">//freopen("input.txt","r",stdin);</span></span><br><span class="line">    <span class="comment">//freopen("output.txt","w",stdout);</span></span><br><span class="line">    <span class="keyword">int</span> n,m;</span><br><span class="line">    <span class="built_in">cin</span>&gt;&gt;n&gt;&gt;m;</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=m;i++)&#123;</span><br><span class="line">        <span class="keyword">int</span> u,v;</span><br><span class="line">        <span class="built_in">cin</span>&gt;&gt;u&gt;&gt;v;</span><br><span class="line">        edge[u].push_back(v);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">/*for(int i=1;i&lt;=n;i++)&#123;</span></span><br><span class="line"><span class="comment">        cout&lt;&lt;i&lt;&lt;":";</span></span><br><span class="line"><span class="comment">        for(auto j:edge[i])&#123;</span></span><br><span class="line"><span class="comment">            cout&lt;&lt;j&lt;&lt;' ';</span></span><br><span class="line"><span class="comment">        &#125;</span></span><br><span class="line"><span class="comment">        cout&lt;&lt;endl;</span></span><br><span class="line"><span class="comment">    &#125;*/</span></span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=n;i++)&#123;</span><br><span class="line">        <span class="keyword">if</span>(!dfn[i])tarjan(i);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">//printf("after tarjan scc=%d\n",scc);</span></span><br><span class="line">    <span class="comment">/*for(int i=1;i&lt;=n;i++)&#123;</span></span><br><span class="line"><span class="comment">        printf("mark[%d]=%d\n",i,mark[i]);</span></span><br><span class="line"><span class="comment">    &#125;*/</span></span><br><span class="line">    <span class="comment">//cut the more</span></span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=n;i++)&#123;</span><br><span class="line">        <span class="keyword">for</span>(<span class="keyword">auto</span> j:edge[i])&#123;</span><br><span class="line">            cut[mark[i]].push_back(mark[j]);</span><br><span class="line">            <span class="comment">//printf("mark[%d]=%d,cut[%d].push(%d)\n",i,mark[i],mark[i],mark[j]);</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">/*for(int i=0;i&lt;scc;i++)&#123;</span></span><br><span class="line"><span class="comment">        for(auto j:edge[i])&#123;</span></span><br><span class="line"><span class="comment">            printf("cut[%d][..]=%d\n",i,j);</span></span><br><span class="line"><span class="comment">        &#125;</span></span><br><span class="line"><span class="comment">    &#125;*/</span></span><br><span class="line">    <span class="comment">//hungarian algorithm</span></span><br><span class="line">    <span class="built_in">memset</span>(match,<span class="number">-1</span>,<span class="keyword">sizeof</span>(match));</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">0</span>;i&lt;scc;i++)&#123;</span><br><span class="line">        <span class="built_in">memset</span>(vis,<span class="number">0</span>,<span class="keyword">sizeof</span>(vis));</span><br><span class="line">        <span class="keyword">if</span>(dfs(i))&#123;</span><br><span class="line">            mat++;</span><br><span class="line">            <span class="comment">//printf("dfs(%d)=true\n",i);</span></span><br><span class="line">        &#125;</span><br><span class="line">        <span class="comment">//printf("hungarian:i=%d,mat=%d\n",i,mat);</span></span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">//printf("after hungarian mat=%d\n",mat);</span></span><br><span class="line">    <span class="comment">//printf("scc=%d,mat=%d\n",scc,mat);</span></span><br><span class="line">    <span class="built_in">cout</span>&lt;&lt;scc-mat&lt;&lt;<span class="built_in">endl</span>;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="E"><a href="index.html#E" class="headerlink" title="E"></a>E</h1><p><a href="https://www.luogu.org/problemnew/show/U53618" target="_blank" rel="noopener">U53618 骗分的回忆</a><br>分类讨论。</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;vector&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> N=<span class="number">50050</span>;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> M=<span class="number">100050</span>;</span><br><span class="line"><span class="built_in">vector</span>&lt;<span class="keyword">int</span>&gt; son[N];</span><br><span class="line"><span class="keyword">int</span> f[N],size[N],op[M],u[M];</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">dfs</span><span class="params">(<span class="keyword">int</span> x)</span></span>&#123;</span><br><span class="line">    <span class="keyword">int</span> ans=<span class="number">1</span>;</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">auto</span> v:son[x])&#123;</span><br><span class="line">        <span class="keyword">if</span>(f[v]==x)ans+=dfs(v);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> size[x]=ans;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">    <span class="keyword">int</span> n,m,root;</span><br><span class="line">    <span class="built_in">scanf</span>(<span class="string">"%d%d"</span>,&amp;n,&amp;m);</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=n;i++)&#123;</span><br><span class="line">        <span class="built_in">scanf</span>(<span class="string">"%d"</span>,&amp;f[i]);</span><br><span class="line">        <span class="keyword">if</span>(f[i]==<span class="number">0</span>)root=i;</span><br><span class="line">        <span class="keyword">else</span> son[f[i]].push_back(i);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">int</span> count0=<span class="number">0</span>,count1=<span class="number">0</span>;</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=m;i++)&#123;</span><br><span class="line">        <span class="built_in">scanf</span>(<span class="string">"%d%d"</span>,&amp;op[i],&amp;u[i]);</span><br><span class="line">        <span class="keyword">if</span>(op[i]==<span class="number">1</span>)count1++;</span><br><span class="line">        <span class="keyword">else</span> <span class="keyword">if</span>(op[i]==<span class="number">0</span>)count0++;</span><br><span class="line">    &#125;</span><br><span class="line">    f[root]=root;</span><br><span class="line">    <span class="keyword">if</span>(count0&lt;=<span class="number">100</span>)&#123;</span><br><span class="line">        dfs(root);</span><br><span class="line">        <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=m;i++)&#123;</span><br><span class="line">            <span class="keyword">if</span>(op[i]==<span class="number">1</span>)</span><br><span class="line">                <span class="built_in">printf</span>(<span class="string">"%d\n"</span>,size[u[i]]);</span><br><span class="line">            <span class="keyword">else</span> <span class="keyword">if</span>(op[i]==<span class="number">0</span>)&#123;</span><br><span class="line">                <span class="keyword">int</span> tu=u[i];</span><br><span class="line">                <span class="keyword">while</span>(f[tu]!=root)&#123;</span><br><span class="line">                    size[f[tu]]-=size[u[i]];</span><br><span class="line">                    tu=f[tu];</span><br><span class="line">                &#125;</span><br><span class="line">                f[u[i]]=root;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;<span class="keyword">else</span> <span class="keyword">if</span>(count1&lt;=<span class="number">100</span>)&#123;</span><br><span class="line">        <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=m;i++)&#123;</span><br><span class="line">            <span class="keyword">if</span>(op[i]==<span class="number">1</span>)&#123;</span><br><span class="line">                dfs(root);</span><br><span class="line">                <span class="built_in">printf</span>(<span class="string">"%d\n"</span>,size[u[i]]);</span><br><span class="line">            &#125;<span class="keyword">else</span> <span class="keyword">if</span>(op[i]==<span class="number">0</span>)&#123;</span><br><span class="line">                <span class="keyword">if</span>(f[u[i]]!=root)son[root].push_back(u[i]);</span><br><span class="line">                f[u[i]]=root;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="F"><a href="index.html#F" class="headerlink" title="F"></a>F</h1><p><a href="https://www.luogu.org/problemnew/show/U53619" target="_blank" rel="noopener">U53619 太空中的箱与球</a><br>模拟。</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cmath&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">double</span> eps=<span class="number">1e-8</span>;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">    <span class="comment">//freopen("input.txt","r",stdin);</span></span><br><span class="line">    <span class="comment">//freopen("output.txt","w",stdout);</span></span><br><span class="line">    <span class="keyword">double</span> x,y,z,bx,by,bz,r,vx,vy,vz,t;</span><br><span class="line">    <span class="built_in">cin</span>&gt;&gt;x&gt;&gt;y&gt;&gt;z&gt;&gt;bx&gt;&gt;by&gt;&gt;bz&gt;&gt;r&gt;&gt;vx&gt;&gt;vy&gt;&gt;vz&gt;&gt;t;</span><br><span class="line">    x-=r,y-=r,z-=r;</span><br><span class="line">    <span class="comment">//printf("x=%lf,y=%lf,z=%lf\n",x,y,z);</span></span><br><span class="line">    <span class="keyword">double</span> dx,dy,dz,tx,ty,tz,tt;</span><br><span class="line">    <span class="keyword">while</span>(<span class="number">1</span>)&#123;</span><br><span class="line">        dx=(vx&gt;<span class="number">0</span>)?(x-bx):(bx-r);</span><br><span class="line">        dy=(vy&gt;<span class="number">0</span>)?(y-by):(by-r);</span><br><span class="line">        dz=(vz&gt;<span class="number">0</span>)?(z-bz):(bz-r);</span><br><span class="line">        tx=(dx&lt;eps)?<span class="number">1e9</span>:(dx/<span class="built_in">fabs</span>(vx));</span><br><span class="line">        ty=(dy&lt;eps)?<span class="number">1e9</span>:(dy/<span class="built_in">fabs</span>(vy));</span><br><span class="line">        tz=(dz&lt;eps)?<span class="number">1e9</span>:(dz/<span class="built_in">fabs</span>(vz));</span><br><span class="line">        tt=min(min(tx,ty),tz);</span><br><span class="line">        <span class="comment">//printf("vx=%lf,vy=%lf,vz=%lf,dx=%lf,dy=%lf,dz=%lf,tx=%lf,ty=%lf,tz=%lf,tt=%lf\n",vx,vy,vz,dx,dy,dz,tx,ty,tz,tt);</span></span><br><span class="line">        <span class="keyword">if</span>(tt&gt;<span class="number">1e9</span><span class="number">-1</span>)<span class="keyword">break</span>;</span><br><span class="line">        <span class="keyword">else</span> <span class="keyword">if</span>(tt&gt;t)<span class="keyword">break</span>;</span><br><span class="line">        <span class="keyword">else</span>&#123;</span><br><span class="line">            bx=bx+vx*tt;</span><br><span class="line">            by=by+vy*tt;</span><br><span class="line">            bz=bz+vz*tt;</span><br><span class="line">            <span class="keyword">if</span>(<span class="built_in">fabs</span>(tx-tt)&lt;eps)&#123;</span><br><span class="line">                vx=-vx;</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span>(<span class="built_in">fabs</span>(ty-tt)&lt;eps)&#123;</span><br><span class="line">                vy=-vy;</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span>(<span class="built_in">fabs</span>(tz-tt)&lt;eps)&#123;</span><br><span class="line">                vz=-vz;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        t-=tt;</span><br><span class="line">        <span class="comment">//printf("t=%lf,bx=%lf,by=%lf,bz=%lf\n",t,bx,by,bz);</span></span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">if</span>(t&gt;eps&amp;&amp;tt&lt;<span class="number">1e9</span><span class="number">-1</span>)&#123;</span><br><span class="line">        bx=bx+vx*t;</span><br><span class="line">        by=by+vy*t;</span><br><span class="line">        bz=bz+vz*t;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"%.2lf %.2lf %.2lf\n"</span>,bx,by,bz);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="G"><a href="index.html#G" class="headerlink" title="G"></a>G</h1><p><a href="https://www.luogu.org/problemnew/show/U53620" target="_blank" rel="noopener">U53620 小南瓜与猫窝</a></p>
<h1 id="H"><a href="index.html#H" class="headerlink" title="H"></a>H</h1><p><a href="https://www.luogu.org/problemnew/show/U53621" target="_blank" rel="noopener">U53621 YHF与他的薯(mei)片(zi)</a></p>
<h1 id="I"><a href="index.html#I" class="headerlink" title="I"></a>I</h1><p><a href="https://www.luogu.org/problemnew/show/U53622" target="_blank" rel="noopener">U53622 编码</a></p>
<h1 id="J"><a href="index.html#J" class="headerlink" title="J"></a>J</h1><p><a href="https://www.luogu.org/problemnew/show/U53623" target="_blank" rel="noopener">U53623 题目是什么能吃吗</a></p>
<h1 id="sort"><a href="index.html#sort" class="headerlink" title="sort"></a>sort</h1><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;vector&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="keyword">int</span> a[<span class="number">1000005</span>];</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">    <span class="keyword">int</span> n;</span><br><span class="line">    <span class="built_in">scanf</span>(<span class="string">"%d"</span>,&amp;n);</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=n;i++)&#123;</span><br><span class="line">        <span class="built_in">scanf</span>(<span class="string">"%d"</span>,&amp;a[i]);</span><br><span class="line">    &#125;</span><br><span class="line">    sort(a+<span class="number">1</span>,a+n+<span class="number">1</span>);</span><br><span class="line">    a[<span class="number">0</span>]=a[n+<span class="number">1</span>]=<span class="number">-1</span>;</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=n;i++)&#123;</span><br><span class="line">        <span class="keyword">if</span>(a[i]!=a[i<span class="number">-1</span>]&amp;&amp;a[i]!=a[i+<span class="number">1</span>])<span class="built_in">printf</span>(<span class="string">"%d "</span>,a[i]);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://tootal.xyz/2018/11/26/软件学院ACM集训队选拔赛第一场/" data-id="cjptu2lt20009t0tk217fl0nd" class="article-share-link">Share</a>
      
      
        <a href="index.html#comments" class="article-comment-link">
          <span class="post-comments-count valine-comment-count" data-xid="/2018/11/26/软件学院ACM集训队选拔赛第一场/" itemprop="commentCount"></span>
          Comments
        </a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="../../../../tags/ACM/index.html">ACM</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="../../../12/01/四种最简真分式的积分/index.html" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          四种最简真分式的积分
        
      </div>
    </a>
  
  
    <a href="../../18/2018级C-第4章课后作业（计科1班、创新班、辅修班）/index.html" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">2018级C++-第4章课后作业（计科1班、创新班、辅修班）</div>
    </a>
  
</nav>

  
</article>



  <section id="comments" class="vcomment">

  </section>
</section>
        
          <aside id="sidebar">
  
    

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/ACM/index.html">ACM</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/C/index.html">C++</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/Math/index.html">Math</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/Minecraft/index.html">Minecraft</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="../../../../tags/ACM/index.html" style="font-size: 20px;">ACM</a> <a href="../../../../tags/C/index.html" style="font-size: 20px;">C++</a> <a href="../../../../tags/Math/index.html" style="font-size: 15px;">Math</a> <a href="../../../../tags/Minecraft/index.html" style="font-size: 10px;">Minecraft</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="http://tootal.xyz/archives/2018/12/">December 2018</a></li><li class="archive-list-item"><a class="archive-list-link" href="http://tootal.xyz/archives/2018/11/">November 2018</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="../../../12/21/Net-Cloud-Music&#32;List&#32;Download/index.html">Net-Cloud-Music List Download</a>
          </li>
        
          <li>
            <a href="../../../12/21/三角函数和差化积、积化和差公式推导记忆/index.html">三角函数和差化积、积化和差公式推导记忆</a>
          </li>
        
          <li>
            <a href="../../../12/17/《高级语言程序设计C++（一）》样卷/index.html">《高级语言程序设计C++（一）》样卷</a>
          </li>
        
          <li>
            <a href="../../../12/14/Minecraft-Server-Tootal-World/index.html">Minecraft Server Tootal World</a>
          </li>
        
          <li>
            <a href="../../../12/10/2018级计科1、计科2、网工、信安班第15周竞赛题/index.html">2018级计科1、计科2、网工、信安班第15周竞赛题</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2018 tootal<br>
      Powered by <a href="https://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>

    </div>
    <nav id="mobile-nav">
  
    <a href="../../../../index.html" class="mobile-nav-link">Home</a>
  
    <a href="../../../../archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="../../../../fancybox/jquery.fancybox.css">
  <script src="../../../../fancybox/jquery.fancybox.pack.js"></script>


<script src="../../../../js/script.js"></script>




  <script src="http://cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src="http://unpkg.com/valine/dist/Valine.min.js"></script>
<script>
    var GUEST_INFO = ['nick','mail','link'];
    var guest_info = 'nick,mail,link'.split(',').filter(function(item){
        return GUEST_INFO.indexOf(item) > -1
    });
    var notify = 'false' == true;
    var verify = 'false' == true;
    new Valine({
        el: '.vcomment',
        notify: notify,
        verify: verify,
        appId: "M3v8N5hOEvMyXAbssqMm35dx-gzGzoHsz",
        appKey: "cPadTqnA1Me5mlv0N4Ix96Xl",
        placeholder: "Please leave your footprints.",
        pageSize:'10',
        avatar:'mm',
        lang:'zh-cn'
    });
</script>

  </div>
<script type="text/x-mathjax-config">
    MathJax.Hub.Config({
        tex2jax: {
            inlineMath: [ ["$","$"], ["\\(","\\)"] ],
            skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code'],
            processEscapes: true
        }
    });
    MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax();
        for (var i = 0; i < all.length; ++i)
            all[i].SourceElement().parentNode.className += ' has-jax';
    });
</script>
<!--script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML"></script>

</body>
</html>